<--- %%NOBANNER%% --> FREQSSR.sas
 BackForward

/*------------------<--  Start of Description -->--------------------\
| Produce an nxn contingency table and append the p-values for the   |
| sign test and Wilcoxon signed rank tests for numeric variables that|
| are repeated ordered categorical responses.                        |
|--------------<--  Start of Files or Arguments Needed -->-----------|
| Parameters: data= name of the sas data set containing the          |
|                   variables for comparison                         |
|             var1= the first variable of interest                   |
|             var2= the second variable of interest                  |
|---------------<--  End of Files or Arguments Needed -->------------|
|--------------------------------------------------------------------|
|----------------<--  Start of Example and Usage -->-----------------|
| Example: data a; set in.6030400; run;                              |
|          %freqssr(a,pre_pain,fu_pain);                             |
| Usaage:  %FREQSSR(DATA,VAR1,VAR2);                                 |
| Reference:                                                         |
|    Follmann, Dean. "Modelling Transitional and Joint Marginal      |
|    Distributions in Repeated Categorical Data", Statistics in      |
|    Medicine, Volume 13, 467-477, 1994.                             |
|                                                                    |
|    Mark, Steven and Gail, Mitchell. "A Comparison of               |
|    Likelihood-Based and Marginal Estimating Equation Methods       |
|    for Analyzing Repeated Ordered Categorical Responses with       |
|    Missing Data: Application to an Intervention Trial of           |
|    Vitamin Prophylaxis for Oesophageal Dysplasia", Statistics      |
|    in Medicine, Volume 13, 479-493, 1994.                          |
\-------------------<--  End of Example and Usage -->---------------*/
%MACRO FREQSSR(DATA,VAR1,VAR2);
/*--------------------------------------------\
| Author:  Steve Wallrichs;                   |
| Created: September 22, 1994;                |
| Purpose: Produce an nxn contingency table   |
|          and append the p-values for the    |
|          sign test and Wilcoxon signed rank |
|          tests for numeric variables that   |
|          are repeated ordered categorical   |
|          responses;                         |
\--------------------------------------------*/
   OPTIONS DQUOTE NOSOURCE NONOTES;
   DATA DIFF;
     SET &DATA;
     DIFF=&VAR1-&VAR2;
     KEEP DIFF &VAR1 &VAR2;
   PROC UNIVARIATE DATA=DIFF NOPRINT;
     VAR DIFF;
     OUTPUT OUT=TESTS PROBM=SIGN_P PROBS=SIGNR_P;
   DATA MACROVAR;
     SET TESTS;
     IF 0<=SIGN_P<=.0001 THEN S_PVAL='<= 0.0001   ';
       ELSE IF .0001